-
Notifications
You must be signed in to change notification settings - Fork 2k
Feature aichat 20250730 and new plugin aiimage
#1187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
plugin/aiimage/config.go
Outdated
) | ||
|
||
// Storage 管理画图配置存储 | ||
type Storage struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
plugin/aiimage/config.go
Outdated
) | ||
|
||
func init() { | ||
if err := os.MkdirAll("data/aiimage", 0755); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用PrivateDataFolder就够了。
plugin/aiimage/config.go
Outdated
if err := os.MkdirAll("data/aiimage", 0755); err != nil { | ||
panic(err) | ||
} | ||
if err := sdb.db.Open(time.Hour * 24); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在触发功能时懒加载,参考其他插件的getdb函数。
plugin/aiimage/config.go
Outdated
} | ||
|
||
// ImageConfig 存储AI画图配置信息 | ||
type ImageConfig struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private,下同。
sdb.RLock() | ||
defer sdb.RUnlock() | ||
cfg := ImageConfig{} | ||
_ = sdb.db.Find("config", &cfg, "WHERE id = 1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无效的封装。应当是
sdb.getConfig() // return imageConfig
然后在sdb.getConfig
中上锁。锁不要暴露给调用者。其他位置同理。
plugin/aiimage/main.go
Outdated
reqData := map[string]interface{}{ | ||
"model": cfg.ModelName, | ||
"prompt": prompt, | ||
"image_size": "1024x1024", | ||
"batch_size": 4, | ||
"num_inference_steps": 20, | ||
"guidance_scale": 7.5, | ||
} | ||
reqBytes, _ := json.Marshal(reqData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reqData := map[string]interface{}{ | |
"model": cfg.ModelName, | |
"prompt": prompt, | |
"image_size": "1024x1024", | |
"batch_size": 4, | |
"num_inference_steps": 20, | |
"guidance_scale": 7.5, | |
} | |
reqBytes, _ := json.Marshal(reqData) | |
reqBytes, _ := json.Marshal(map[string]interface{}{ | |
"model": cfg.ModelName, | |
"prompt": prompt, | |
"image_size": "1024x1024", | |
"batch_size": 4, | |
"num_inference_steps": 20, | |
"guidance_scale": 7.5, | |
}) |
reqBytes, _ := json.Marshal(reqData) | ||
|
||
// 发送API请求 | ||
data, err := web.RequestDataWithHeaders( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个🉑放AnimeAPI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api不固定暂时先别放那边
还有就是起个好点的PR名字,如
|
aiimage
aiimage
aiimage
No description provided.